﻿@{
    Layout = null;
}
@model System.Collections.IEnumerable
<!DOCTYPE html>

<html>

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=7"/>
    <title>Left</title>
    @if (false)
    {
        <script src="../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

      <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    @Html.DevExpress().GetStyleSheets(
        new StyleSheet { ExtensionType = ExtensionType.Splitter, Theme = DevExpressHelper.Theme }

)
    @Html.DevExpress().GetScripts(
            new Script { ExtensionType = ExtensionType.Splitter }
    )

    <script>
//        function nodeClick(s, e) {
//            var names = e.node.name.split('|');
//            if (names.length > 1) {
//                parent.$("#contentframe").attr("src", names[0]);
//            }
//        }

//        function nodeInit(s, e) {
//            var hdFocusNodeName = $("#hdFocusNodeName").val();
//            var node = null;
//            if (hdFocusNodeName == "") {
//                node = LeftTreeView.GetSelectedNode();

//                if (node.name.indexOf('|') == -1 && node.nodes.length > 0) {
//                    node = node.nodes[0];
//                    while (node.name.indexOf('|') == -1 && node.nodes.length > 0) {
//                        node = node.nodes[0];
//                    }
//                }
//            }
//            else {
//                node = LeftTreeView.GetNodeByName(hdFocusNodeName);
//            }
//            if (node) {
//                LeftTreeView.SetSelectedNode(node);
//                var names = node.name.split('|');
//                if (names.length > 1) {
//                    parent.$("#contentframe").attr("src", names[0] + "?userID=" + names[1]);
//                }
//            }
//        }
        function nodeClick(s, e) {
            if (e.node.nodes.length > 0) {

            }
            else {
                var names = e.node.name.split('|');
                if (names.length > 1) {
                    parent.contentframe.url(names[1]);
                }
            }
        }
        
    </script>
</head>
<body>
@Html.Partial("LoadPanelPartial")
   <div class="leftPanel">
        @Html.DevExpress().TreeView(settings =>
{
    settings.Name = "LeftTreeView";
    settings.ShowTreeLines = true;
    settings.AllowSelectNode = true;
    settings.NameField = "Id";
    settings.TextField = "Name";
    settings.Width = 150;
    settings.ImageUrlField = "ImageUrl";
    settings.ClientSideEvents.NodeClick = "function(s, e) { nodeClick(s,e) }";
    //settings.ClientSideEvents.Init = "function(s, e) { nodeInit(s,e) }";  
    settings.PreRender = (source, e) =>
    {
        ASPxTreeView treeView = (ASPxTreeView)source;
        treeView.ExpandAll();
        
    };

}).Bind(Model).GetHtml()
@Html.Hidden("hdFocusNodeName", ViewData["focusNodeName"])
    </div>
</body>
</html>

